import Vue from 'vue'
import VueRouter from 'vue-router'
import VueResource from 'vue-resource'
import UI from './ui-components'

Vue.use(VueRouter)
Vue.use(VueResource)
Vue.use(UI)

Vue.http.interceptors.push((request, next) => {
  if (request.url.indexOf('/c/') === -1) {
    const token = window.sessionStorage.getItem('token')
    request.headers['Authorization'] = 'Bearer ' + token
  }
  next((response) => {})
})

import App from './App'

const router = new VueRouter({
  history: true
})

router.map(require('./routes'))

router.start(App, '#app')
